﻿using System;
using BITS.PreCompiler.CSharp.Syntax;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Attribute = BITS.PreCompiler.CSharp.Syntax.Attribute;

namespace BITS.PreCompiler.CSharp.Tests.Syntax
{
    [TestClass]
    public class TestAttribute : TestBase
    {
        [TestMethod]
        public void Create_Attribute()
        {
            var proeprty = new Attribute("Create_Attribute");

            var expectet = Comparer.Create_Attribute();
            var actual   = proeprty.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }


        [TestMethod]
        public void Create_Attribute_With_Parameters()
        {
            var proeprty = new Attribute("Create_Attribute_With_Parameters")
                .Add(new AttributeArgument("1"))
                .Add(new AttributeArgument("2"))
                .Add(new AttributeArgument("3"));

            var expectet = Comparer.Create_Attribute_With_Parameters();
            var actual   = proeprty.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }

        [TestMethod]
        public void Create_Attribute_With_Named_Parameters()
        {
            var proeprty = new Attribute("Create_Attribute_With_Named_Parameters")
                .Add(new AttributeArgument("1", "Name"));

            var expectet = Comparer.Create_Attribute_With_Named_Parameters();
            var actual   = proeprty.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }

        [TestMethod]
        public void Create_AttributeDeclaration()
        {
            var proeprty = new Attribute("AttributeUsage")
                .Add(new AttributeArgument("AttributeTargets.Interface | AttributeTargets.Class"))
                .Add(new AttributeArgument("true", "Inherited"))
                .Add(new AttributeArgument("false", "AllowMultiple"));

            var expectet = Comparer.Create_AttributeDeclaration();
            var actual = proeprty.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }



        public static class Comparer
        {
            public static String Create_Attribute()
            {
                return
@"Create_Attribute";
            }

            public static String Create_Attribute_With_Parameters()
            {
                return
@"Create_Attribute_With_Parameters(1, 2, 3)";
            }

            public static String Create_Attribute_With_Named_Parameters()
            {
                return
@"Create_Attribute_With_Named_Parameters(Name = 1)";
            }

            public static String Create_AttributeDeclaration()
            {
                return
@"AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class, Inherited = true, AllowMultiple = false)";
            }
        }
    }
}
